<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>部门管理</title>
    <th:block th:include="statics/common/page/header"></th:block>
    <link rel="stylesheet" th:href="@{../statics/css/upload-template.css}"/>
</head>
<body>
<div id="orgCompany" v-cloak>
    <div v-show="showList">
        <Row :gutter="16">
            <div class="search-group">
                <i-button type="ghost" @click="reload"><i class="fa fa-refresh"></i>&nbsp;刷新</i-button>
            </div>
            <div class="buttons-group">
                <!-- #if($shiro.hasPermission("sys:dept:save")) -->
                <i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
                <!-- #end
                #if($shiro.hasPermission("sys:dept:update")) -->
                <i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
                <!-- #end
                #if($shiro.hasPermission("sys:dept:delete")) -->
                <i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
                <!-- #end -->
            </div>
        </Row>
        <table id="orgCompanyGrid"></table>
    </div>

    <Card v-show="!showList">
        <p slot="title" style="height: 35px;">{{title}}
            <i-button type="warning" @click="reload" style="margin-right: 8px;float: right;"/>
            返回</i-button></p>
        <i-form ref="formValidate" :model="dept" :rules="ruleValidate" :label-width="120">
            <Form-item label="公司简称" prop="name" v-if="dept.type == 1">
                <i-input v-model="dept.name" placeholder="公司简称" style="width: 320px;"/>
            </Form-item>
            <Form-item label="上级部门" prop="parentName">
                <i-input type="text" v-model="dept.parentName" icon="eye" readonly="readonly"
                         @on-click="deptTree" placeholder="上级部门" style="width: 320px;"/>
            </Form-item>
            <Form-item label="类型" prop="type">
                <Radio-group v-model="dept.type">
                    <Radio label="1">
                        <span>公司</span>
                    </Radio>
                    <Radio label="2">
                        <span>大区</span>
                    </Radio>
                </Radio-group>
            </Form-item>
            <Form-item label="大区名称" prop="name" v-if="dept.type == 2">
                <i-input v-model="dept.name" placeholder="大区名称" style="width: 320px;"/>
            </Form-item>
            <Form-item label="公司全称" prop="allName" v-if="dept.type == 1">
                <i-input v-model="dept.allName" placeholder="公司全称" style="width: 320px;"/>
            </Form-item>
            <Form-item label="公司地址" prop="address" v-if="dept.type == 1">
                <i-input v-model="dept.address" placeholder="公司地址" style="width: 320px;"/>
            </Form-item>
            <Form-item label="公司电话" prop="tel" v-if="dept.type == 1">
                <i-input v-model="dept.tel" placeholder="公司电话" style="width: 320px;"/>
            </Form-item>
            <Form-item label="营业执照" prop="license" v-if="dept.type == 1">
            	<div class="multiple-template-upload-list" v-for="item in uploadLicenseList">
			        <template v-if="item.status === 'finished' ">
			            <img :src="item.url">
			            <div class="multiple-template-upload-list-cover">
			                <Icon type="ios-eye-outline" @click.native="handleView(item)"></Icon>
			                <Icon type="ios-trash-outline" @click.native="handleRemove('license')"></Icon>
			            </div>
			        </template>
			        <template v-else>
			        	<img th:src="@{../statics/img/loading.gif}">
			            <!-- <Progress :percent="item.percentage" hide-info></Progress> -->
			        </template>
			    </div>
            
            	<Upload ref="uploadLicenseref" :show-upload-list="false" :default-file-list="uploadLicenseList" :on-success="handleSuccessLicense"
			        :format="['jpg','jpeg','png']" :max-size="4096" :on-format-error="handleImgFormatError" :on-exceeded-size="handleImgMaxSize"
			        :before-upload="handleLicenseImgBeforeUpload" multiple  action="http://upload.qiniu.com" :data="uploadInfo" style="display: inline-block;width:58px;">
			        <div class="multiple-template-upload-list" style="border: darkgrey 1px dashed;">
			        	<Icon type="camera" size="20"></Icon>
			        </div>
			    </Upload>
            </Form-item>
            <Form-item label="法人姓名" prop="legal" v-if="dept.type == 1">
                <i-input v-model="dept.legal" placeholder="法人姓名" style="width: 320px;"/>
            </Form-item>
            <Form-item label="法人身份证正面" prop="idcardPositive" v-if="dept.type == 1">
                <div class="multiple-template-upload-list" v-for="item in uploadIdcardPositiveList">
			        <template v-if="item.status === 'finished' ">
			            <img :src="item.url">
			            <div class="multiple-template-upload-list-cover">
			                <Icon type="ios-eye-outline" @click.native="handleView(item)"></Icon>
			                <Icon type="ios-trash-outline" @click.native="handleRemove('idcardPositive')"></Icon>
			            </div>
			        </template>
			        <template v-else>
			        	<img th:src="@{../statics/img/loading.gif}">
			            <!-- <Progress :percent="item.percentage" hide-info></Progress> -->
			        </template>
			    </div>
            
            	<Upload ref="uploadIdcardPositiveref" :show-upload-list="false" :default-file-list="uploadIdcardPositiveList" :on-success="handleSuccessIdcardPositive"
			        :format="['jpg','jpeg','png']" :max-size="4096" :on-format-error="handleImgFormatError" :on-exceeded-size="handleImgMaxSize"
			        :before-upload="handleIdcardPositiveImgBeforeUpload" multiple  action="http://upload.qiniu.com" :data="uploadInfo" style="display: inline-block;width:58px;">
			        <div class="multiple-template-upload-list" style="border: darkgrey 1px dashed;">
			        	<Icon type="camera" size="20"></Icon>
			        </div>
			    </Upload>
            </Form-item>
            <Form-item label="法人身份证反面" prop="idcardReverse" v-if="dept.type == 1">
                <div class="multiple-template-upload-list" v-for="item in uploadIdcardReverseList">
			        <template v-if="item.status === 'finished' ">
			            <img :src="item.url">
			            <div class="multiple-template-upload-list-cover">
			                <Icon type="ios-eye-outline" @click.native="handleView(item)"></Icon>
			                <Icon type="ios-trash-outline" @click.native="handleRemove('idcardReverse')"></Icon>
			            </div>
			        </template>
			        <template v-else>
			        	<img th:src="@{../statics/img/loading.gif}">
			            <!-- <Progress :percent="item.percentage" hide-info></Progress> -->
			        </template>
			    </div>
            
            	<Upload ref="uploadIdcardReverseref" :show-upload-list="false" :default-file-list="uploadIdcardReverseList" :on-success="handleSuccessIdcardReverse"
			        :format="['jpg','jpeg','png']" :max-size="4096" :on-format-error="handleImgFormatError" :on-exceeded-size="handleImgMaxSize"
			        :before-upload="handleIdcardReverseImgBeforeUpload" multiple action="http://upload.qiniu.com" :data="uploadInfo" style="display: inline-block;width:58px;">
			        <div class="multiple-template-upload-list" style="border: darkgrey 1px dashed;">
			        	<Icon type="camera" size="20"></Icon>
			        </div>
			    </Upload>
            </Form-item>
            <Form-item label="联系人名称" prop="attn" v-if="dept.type == 1">
                <i-input v-model="dept.attn" placeholder="联系人名称" style="width: 320px;"/>
            </Form-item>
            <Form-item label="联系人电话" prop="phone" v-if="dept.type == 1">
                <i-input v-model="dept.phone" placeholder="联系人电话" style="width: 320px;"/>
            </Form-item>

            <Form-item label="排序号" prop="orderNum">
                <Input-number :min="0" :step="1" v-model="dept.orderNum" placeholder="排序号" style="width: 320px;"/>
            </Form-item>
            <Form-item>
                <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
            </Form-item>
        </i-form>
    </Card>
</div>

<!-- 选择部门 -->
<div id="orgCompanyLayer" style="display: none;padding:10px;">
    <ul id="orgCompanyTree" class="ztree"></ul>
</div>

<!-- <script src="${rc.contextPath}/js/sys/dept.js?_${date.systemTime}"></script> -->
<script th:src="@{../statics/js/org/company.js}"></script>
</body>
</html>